package com.simpleframe.views.chart.attribution;

/**
 * 横坐标属性
 * @author Administrator
 *
 */
public class ChartXAxis {
	
	/**
	 * 横坐标的颜色
	 */
	private String colour;
	
	/**
	 * 横网格的颜色
	 */
	private String gridColour;
	
	/**
	 * 轴线宽度
	 */
	private int stroke;
	
	/**
	 * 轴刻度线高度值
	 * 
	 */
	private int tickHeight;
	
	/**
	 * 轴是否显示3D效果
	 * 0：2D
	 * 非0：3D
	 */
	private int threeD;
	
	/**
	 * 坐标跨度
	 */
	private int steps;
	
	/**
	 * 坐标刻度的名称
	 */
	private String[] labels;
	
	public ChartXAxis(String colour, String gridColour, int stroke, int tickHeight,
			int threeD, String[] labels) {
		this.colour = colour;
		this.gridColour = gridColour;
		this.stroke = stroke;
		this.tickHeight = tickHeight;
		this.threeD = threeD;
		this.labels = labels;
	}

	public ChartXAxis(){
		
	}
	
	/**
	 * 将X轴的属性以字符串的形式返回
	 * @return
	 */
	public String getXAxisString(){
		StringBuffer sb = new StringBuffer();
		sb.append(ChartTool.addQuotes("x_axis")+":\n");
		sb.append(ChartTool.addHT("{\n"));
		sb.append("\t");
		sb.append(ChartTool.addQuotes("colour") + ":");
		sb.append(ChartTool.addQuotes(colour) + ",\n");

		sb.append("\t");
		sb.append(ChartTool.addQuotes("grid-colour") + ":");
		sb.append(ChartTool.addQuotes(gridColour) + ",\n");
		
		sb.append("\t");
		sb.append(ChartTool.addQuotes("stroke") + ":");
		sb.append(ChartTool.checkField(""+stroke) + ",\n");

		sb.append("\t");
		sb.append(ChartTool.addQuotes("tick-height") + ":");
		sb.append(ChartTool.checkField(""+tickHeight) + ",\n");

		sb.append("\t");
		sb.append(ChartTool.addQuotes("3d") + ":");
		sb.append(ChartTool.checkField(""+threeD) + ",\n");
		
		sb.append("\t");
		sb.append(ChartTool.addQuotes("labels") + ":\n");
		sb.append("\t\t{\n");
		
		sb.append("\t\t");
		sb.append(ChartTool.addQuotes("steps") + ":");
		sb.append(ChartTool.checkField(""+steps) + ",\n");
		
		sb.append("\t\t");
		sb.append(ChartTool.addQuotes("labels") + ":[");
		if (labels != null) {
			for (int i = 0; i < labels.length; i++) {
				if (i != labels.length - 1) {
					sb.append(ChartTool.addQuotes(labels[i])+",");
				} else {
					sb.append(ChartTool.addQuotes(labels[i]));
				}
			}
		}
		sb.append("]\n");
		sb.append("\t\t}\n");
		sb.append(ChartTool.addHT("},\n"));
		return sb.toString();
	}
	
	/**
	 * 默认设定
	 */
	public void DefaultSetting(){
		colour = new String("#000000");
		gridColour = new String("#eeeeee");
		stroke = 1;
		tickHeight =1;
		steps = 7;
	}
	
	
	/**
	 * 以下为属性的get和set方法
	 * @return
	 */
	
	
	public String getColour() {
		return colour;
	}

	public void setColour(String colour) {
		this.colour = colour;
	}

	public String getGridColour() {
		return gridColour;
	}

	public void setGridColour(String gridColour) {
		this.gridColour = gridColour;
	}

	public int getStroke() {
		return stroke;
	}

	public void setStroke(int stroke) {
		this.stroke = stroke;
	}

	public int getTickHeight() {
		return tickHeight;
	}

	public void setTickHeight(int tickHeight) {
		this.tickHeight = tickHeight;
	}

	public int getThreeD() {
		return threeD;
	}

	public void setThreeD(int threeD) {
		this.threeD = threeD;
	}

	public String[] getLabels() {
		return labels;
	}

	public void setLabels(String[] labels) {
		this.labels = labels;
	}

	public int getSteps() {
		return steps;
	}

	public void setSteps(int steps) {
		this.steps = steps;
	}
}
